package edu.washington.ling.syntric.io;

import edu.washington.ling.syntric.struct.error.InvalidValueException;
import edu.washington.ling.syntric.struct.tree.Tree;
public abstract class TreeWriter {
	
	public static TreeWriter newWriter(String format) throws InvalidValueException {
		TreeWriter tw;
		if (format.equals("ssf"))
			tw = new TreeWriterSSF();
		else if (format.equals("latex")) 
			tw = new TreeWriterLaTeX();
		else if (format.equals("ptb"))
			tw = new TreeWriterPTB();
		else if (format.equals("conll"))
			tw = new TreeWriterCoNLL();
		else if (format.equals("links"))
			tw = new TreeWriterLinks();
		else {
			String[] possibleFormats = {"ssf", "latex", "ptb", "conll", "links"};
			throw new InvalidValueException("Specified tree format unknown.", format, possibleFormats);
		}
		return tw;
	}

	public abstract TreeRepresentation writeTree(Tree tree);
}
